﻿<UserControl x:Class="TestCaseManagerApp.Views.TestCaseBatchDuplicateView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             xmlns:helpers="clr-namespace:AAngelov.Utilities.UI.ControlExtensions;assembly=AAngelov.Utilities.UI"
             xmlns:System="clr-namespace:System;assembly=mscorlib"
             xmlns:enums="clr-namespace:TestCaseManagerCore.BusinessLogic.Enums;assembly=TestCaseManagerCore"
             mc:Ignorable="d" Loaded="UserControl_Loaded">
    <Grid>
        <ProgressBar Name="progressBar" Minimum="0" Maximum="1" Height="16" IsIndeterminate="True" Margin="0,0,0,16" />
        <Grid Name="mainGrid" Visibility="Hidden">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="3*" />
                <ColumnDefinition Width="1*" />
                <ColumnDefinition Width="8*" />
            </Grid.ColumnDefinitions>
            <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.ColumnSpan="2">
                <TextBlock Text="Find | Replace | Duplicate" Margin="10,0,10,30"  Height="Auto" Width="Auto" FontWeight="Bold" FontSize="26" HorizontalAlignment="Left" />
                <mui:ModernButton Name="btnInfo" HorizontalAlignment="Left" Grid.Row="0" Margin="10,0,10,45" Click="btnInfo_Click" IconData="F1 M 38,19C 48.4934,19 57,27.5066 57,38C 57,48.4934 48.4934,57 38,57C 27.5066,57 19,48.4934 19,38C 19,27.5066 27.5066,19 38,19 Z M 33.25,33.25L 33.25,36.4167L 36.4166,36.4167L 36.4166,47.5L 33.25,47.5L 33.25,50.6667L 44.3333,50.6667L 44.3333,47.5L 41.1666,47.5L 41.1666,36.4167L 41.1666,33.25L 33.25,33.25 Z M 38.7917,25.3333C 37.48,25.3333 36.4167,26.3967 36.4167,27.7083C 36.4167,29.02 37.48,30.0833 38.7917,30.0833C 40.1033,30.0833 41.1667,29.02 41.1667,27.7083C 41.1667,26.3967 40.1033,25.3333 38.7917,25.3333 Z "/>
            </StackPanel>
            <StackPanel Orientation="Vertical" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2">
                <Grid >
                    <Grid.Resources>
                        <ObjectDataProvider x:Key="dataFromEnum" MethodName="GetValues"
                                            ObjectType="{x:Type System:Enum}">
                            <ObjectDataProvider.MethodParameters>
                                <x:Type TypeName="enums:Priority"/>
                            </ObjectDataProvider.MethodParameters>
                        </ObjectDataProvider>
                    </Grid.Resources>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="4*" />
                        <ColumnDefinition Width="2*" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="New Suite" Margin="10,0,0,0" Height="25" Width="Auto" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="0" IsEnabled="{Binding ShowTestCaseSpecificFields}"/>
                    <ComboBox Height="25" Margin="10,0,0,20" Name="cbSuite" SelectedIndex="0" HorizontalAlignment="Stretch" ItemsSource="{Binding ObservableTestSuites}" DisplayMemberPath="Title"
                              IsTextSearchEnabled="True" helpers:ComboBoxDropdownExtensions.OpenDropDownAutomatically="True" IsEditable ="True" MouseEnter="cbSuite_MouseEnter" 
                              SelectedValue="{Binding Path=ReplaceContext.SelectedSuite, Mode=TwoWay}" MouseMove="cbSuite_MouseMove" Grid.Row="1" Grid.Column="0" IsEnabled="{Binding ShowTestCaseSpecificFields}"/>
                    <TextBlock Text="Priority" Margin="10,0,0,0" Height="25" Width="Auto" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="1"/>
                    <ComboBox Height="25" Margin="10,0,0,20" Name="cbPriority" SelectedIndex="0" HorizontalAlignment="Stretch" ItemsSource="{Binding Source={StaticResource dataFromEnum}}" SelectedValue="{Binding Path=ReplaceContext.SelectedPriority, Mode=TwoWay}"
                              IsTextSearchEnabled="True" helpers:ComboBoxDropdownExtensions.OpenDropDownAutomatically="True" IsEditable ="True" MouseEnter="cbPriority_MouseEnter"
                              MouseMove="cbPriority_MouseMove"  Grid.Row="1" Grid.Column="1"/>
                    <TextBlock Text="Assigned To" Margin="10,0,0,0" Height="25" Width="Auto" HorizontalAlignment="Left" Grid.Row="2" Grid.Column="0"/>
                    <ComboBox Height="25" Margin="10,0,0,20" Name="cbTeamFoundationIdentityNames" SelectedIndex="0" HorizontalAlignment="Stretch" ItemsSource="{Binding ObservableTeamFoundationIdentityNames}"
                              SelectedValue="{Binding Path=ReplaceContext.SelectedTeamFoundationIdentityName, Mode=TwoWay}" DisplayMemberPath="DisplayName" IsTextSearchEnabled="True" 
                              helpers:ComboBoxDropdownExtensions.OpenDropDownAutomatically="True" IsEditable ="True" MouseEnter="cbTeamFoundationIdentityNames_MouseEnter"
                              MouseMove="cbTeamFoundationIdentityNames_MouseMove"  Grid.Row="3" Grid.Column="0" />
                </Grid>
            </StackPanel>
            <StackPanel Orientation="Vertical" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2">
                <StackPanel Orientation="Horizontal">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <TextBlock Text="Replace In Titles:" Margin="10,0,10,10" Height="25" Width="Auto" HorizontalAlignment="Left" Grid.Column="0" Grid.Row="0"/>
                        <TextBlock Text="Replace In Test Steps:" Margin="10,0,10,10" Height="25" Width="Auto" HorizontalAlignment="Left" Grid.Column="0" Grid.Row="1"/>
                        <TextBlock Text="Replace Shared Steps:" Margin="10,0,10,30" Height="25" Width="Auto" HorizontalAlignment="Left" Grid.Column="0" Grid.Row="2" IsEnabled="{Binding ShowTestCaseSpecificFields}"/>

                        <CheckBox Margin="10,0,10,10" HorizontalAlignment="Left" IsChecked="{Binding Path=ReplaceContext.ReplaceInTitles, Mode=TwoWay}" Grid.Column="1" Grid.Row="0"/>
                        <CheckBox Margin="10,0,10,10" HorizontalAlignment="Left" IsChecked="{Binding Path=ReplaceContext.ReplaceInTestSteps, Mode=TwoWay}" Grid.Column="1" Grid.Row="1"/>
                        <CheckBox Margin="10,0,10,30" HorizontalAlignment="Left" IsChecked="{Binding Path=ReplaceContext.ReplaceSharedSteps, Mode=TwoWay}" Grid.Column="1" Grid.Row="2" IsEnabled="{Binding ShowTestCaseSpecificFields}"/>

                    </Grid>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <TextBlock Text="Change Priorities" Margin="10,0,10,10" Height="25" Width="Auto" HorizontalAlignment="Left" Grid.Column="0" Grid.Row="0"/>
                        <TextBlock Text="Change Owner" Margin="10,0,10,10" Height="25" Width="Auto" HorizontalAlignment="Left" Grid.Column="0" Grid.Row="1"/>

                        <CheckBox Margin="10,0,10,10" HorizontalAlignment="Left" IsChecked="{Binding Path=ReplaceContext.ChangePriorities, Mode=TwoWay}" Grid.Column="1" Grid.Row="0"/>
                        <CheckBox Margin="10,0,10,10" HorizontalAlignment="Left" IsChecked="{Binding Path=ReplaceContext.ChangeOwner, Mode=TwoWay}" Grid.Column="1" Grid.Row="1"/>
                    </Grid>
                </StackPanel>
            </StackPanel>

            <DataGrid Name="dgSharedStepIds" ItemsSource="{Binding ReplaceContext.ObservableSharedStepIdReplacePairs}" CanUserAddRows="True" AutoGenerateColumns="False"  Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" IsEnabled="{Binding ShowTestCaseSpecificFields}">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Old Shared Step ID" Binding="{Binding OldSharedStepId}" Width="*">
                        <DataGridTextColumn.HeaderStyle>
                            <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                            </Style>
                        </DataGridTextColumn.HeaderStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="New Shared Step ID" Binding="{Binding NewSharedStepIds}" Width="*">
                        <DataGridTextColumn.HeaderStyle>
                            <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                            </Style>
                        </DataGridTextColumn.HeaderStyle>
                    </DataGridTextColumn>
                </DataGrid.Columns>
            </DataGrid>

            <GridSplitter Height="5" ResizeDirection="Auto"  HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2"/>

            <DataGrid Name="dgTextsToBeReplaced" ItemsSource="{Binding ReplaceContext.ObservableTextReplacePairs}"  CanUserAddRows="True" AutoGenerateColumns="False" Grid.Row="5"   Grid.Column="0" Grid.ColumnSpan="2">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Old Text" Binding="{Binding OldText}" Width="*">
                        <DataGridTextColumn.HeaderStyle>
                            <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                            </Style>
                        </DataGridTextColumn.HeaderStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="New Text" Binding="{Binding NewText}" Width="*">
                        <DataGridTextColumn.HeaderStyle>
                            <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                            </Style>
                        </DataGridTextColumn.HeaderStyle>
                    </DataGridTextColumn>
                </DataGrid.Columns>
            </DataGrid>

            <Grid Grid.Row="0" Grid.Column="2" Margin="10,0,0,10">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="4.5*" />
                    <ColumnDefinition Width="2.3*" />
                    <ColumnDefinition Width="1.8*" />
                    <ColumnDefinition Width="1.4*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <TextBox Name="tbTitleFilter" Margin="10,0,0,10" Height="25" Text="{Binding InitialViewFilters.TitleFilter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                         GotFocus="tbTitleFilter_GotFocus" LostFocus="tbTitleFilter_LostFocus" KeyUp="tbTitleFilter_KeyUp" Grid.Column="0" />
                <TextBox Name="tbSuiteFilter" Margin="10,0,0,10" Height="25" Text="{Binding InitialViewFilters.SuiteFilter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                         GotFocus="tbTextSuiteFilter_GotFocus" LostFocus="tbSuiteFilter_LostFocus" KeyUp="tbSuiteFilter_KeyUp" Grid.Column="1" IsEnabled="{Binding ShowTestCaseSpecificFields}"/>
                <TextBox Name="tbAssignedToFilter" Margin="10,0,0,10" Height="25" Text="{Binding InitialViewFilters.AssignedToFilter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                         GotFocus="tbAssignedToFilter_GotFocus"  LostFocus="tbAssignedToFilter_LostFocus"  KeyUp="tbAssignedToFilter_KeyUp"  Grid.Column="2"/>
                <TextBox Name="tbPriorityFilter" Margin="10,0,0,10" Height="25" Text="{Binding InitialViewFilters.PriorityFilter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                         GotFocus="tbPriorityFilter_GotFocus"  LostFocus="tbPriorityFilter_LostFocus" KeyUp="tbPriorityFilter_KeyUp" Grid.Column="3" />
                <TextBox Name="tbAdvancedSearch" Text="{Binding InitialViewFilters.AdvancedSearchFilter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                     Height="25" Grid.ColumnSpan="5" Grid.Column="0" Grid.Row="1" Margin="10,10,0,10" 
                     GotFocus="tbAdvancedSearch_GotFocus"  LostFocus="tbAdvancedSearch_LostFocus"/>
                <Button Name="btnAdvancedSearch" Content="Search" Height="0" Width="0"
                    Click="btnAdvancedSearch_Click"  IsDefault="True" Visibility="Visible"/>
            </Grid>

            <DataGrid AutoGenerateColumns="False" Name="dgTestCases" IsReadOnly="True" SelectionMode="Extended"
                      SelectedCellsChanged="dgTestCases_SelectedCellsChanged" Grid.Row="1" Grid.RowSpan="5" Grid.Column="2" Margin="10,10,0,10">
                <DataGrid.ItemContainerStyle>
                    <Style TargetType="{x:Type DataGridRow}"  BasedOn="{StaticResource {x:Type DataGridRow}}">
                        <EventSetter Event="MouseDoubleClick" Handler="dgTestCases_MouseDoubleClick" />
                        <EventSetter Event="PreviewKeyDown" Handler="dgTestCases_PreviewKeyDown" />
                    </Style>
                </DataGrid.ItemContainerStyle>
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Title" Binding="{Binding Title}" Width="5*">
                        <DataGridTextColumn.HeaderStyle>
                            <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                            </Style>
                        </DataGridTextColumn.HeaderStyle>
                    </DataGridTextColumn>

                    <DataGridTextColumn Header="Suite" Binding="{Binding ITestSuiteBase.Title}" Width="2.8*">
                        <DataGridTextColumn.HeaderStyle>
                            <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                            </Style>
                        </DataGridTextColumn.HeaderStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="Assigned To" Binding="{Binding TeamFoundationIdentityName.DisplayName}" Width="2.2*">
                        <DataGridTextColumn.HeaderStyle>
                            <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                            </Style>
                        </DataGridTextColumn.HeaderStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="Priority" Binding="{Binding Priority}" Width="1.2*">
                        <DataGridTextColumn.HeaderStyle>
                            <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                            </Style>
                        </DataGridTextColumn.HeaderStyle>
                    </DataGridTextColumn>
                </DataGrid.Columns>
            </DataGrid>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="2">
                <Button Name="btnFindAndReplace" Margin="10,20,30,0" Height="50" Width="120" Content="Replace" HorizontalAlignment="Left"
                        VerticalAlignment="Center" Click="btnFindAndReplace_Click" Grid.Row="3" Grid.Column="0" FontWeight="Bold"
                        ToolTip="Applies Changes to All Specified Properties to All Selected Test Cases."/>
                <Button Name="btnBatchDuplicate" Margin="0,20,10,0" Height="50" Width="120" Content="Duplicate" HorizontalAlignment="Left" 
                        VerticalAlignment="Center" Click="btnBatchDuplicate_Click" Grid.Row="3" Grid.Column="0" FontWeight="Bold"
                        ToolTip="Duplicates All Selected Test Cases with Specified Changed Properties."/>
              
            </StackPanel>

            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.Row="6" Grid.Column="2">
                <TextBlock Text="Selected Count:" Margin="0,20,10,0" Height="25" Width="Auto" FontWeight="Bold"/>
                <TextBlock Name="tbSelectedTestCaseCount" Text="{Binding SelectedEntitiesCount}"  Margin="10,20,30,0" Height="25" Width="Auto" />
                <TextBlock Text="Count:" Margin="0,20,10,0" Height="25" Width="Auto" FontWeight="Bold"/>
                <TextBlock Name="tbTestCaseCount" Text="{Binding EntitiesCount}"  Margin="10,20,10,0" Height="25" Width="Auto" />
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
